<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <h1>0</h1>

    <script>
      let h = document.querySelector("h1");
      let count = 0;
      let timer = setInterval(() => {
        count++;
        h.innerText = count;
        if (count >= 50) {
          clearInterval(timer);
        }
      }, 100);
      setTimeout(() => {
        alert("时间到！");
      }, 3000);
    </script>
  </body>
</html>
